package top.yamhk.agent.entity.request;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import top.yamhk.agent.entity.enums.MsgType;

import java.util.Arrays;
import java.util.List;

/**
 * 消息创建请求类
 *
 * @author 庆 HongKong
 * @date 2020/8/28 8:36
 */
@Setter
@Getter
@ToString
@EqualsAndHashCode(callSuper = true)
public class MsgCreateRequest extends BaseSrcCreateRequest {
    /**
     * 消息类型
     */
    private String itemType = "1";
    /**
     * 父id
     */
    private String parentId = "-1";
    /**
     * 发给谁
     */
    private String addressee = "";
    /**
     * 发送人
     */
    private String msgFrom;
    /**
     * 消息频道
     */
    private String msgGroup;
    /**
     * 消息频道
     */
    private String msgType = "1";
    /**
     * 消息字符集
     */
    private String charset = "utf-8";
    /**
     * 渲染
     */
    private String rendering = "渲染配置";
    /**
     * 消息内容
     */
    private String content = "消息内容";

    public String buildMsgGroup() {
        List<String> msgGroup = Arrays.asList(this.msgFrom, this.addressee);
        if (this.itemType.equals(Integer.toString(MsgType.SINGLE2SINGLE.getCode()))) {
            msgGroup.sort(String::compareTo);
            return msgGroup.toString();
        } else {
            return this.msgGroup;
        }
    }

}